package com.sample.springbatch.job.sample.processor;

import com.sample.springbatch.job.exception.MySkipException;
import com.sample.springbatch.model.RepayOrderInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.batch.item.ItemProcessor;
import org.springframework.beans.BeanUtils;

import java.util.Date;

/**
 * Created by zwg on 2017/7/20.
 */
public class RepayOrderProcessor implements ItemProcessor<RepayOrderInfo,RepayOrderInfo> {

    private static final Logger log = LoggerFactory.getLogger(RepayOrderProcessor.class);

    @Override
    public RepayOrderInfo process(final RepayOrderInfo order) throws Exception {
        //数据进行封装
        RepayOrderInfo repayOrderInfo = new RepayOrderInfo();
        BeanUtils.copyProperties(order,repayOrderInfo);
        repayOrderInfo.setBussDate(new Date());
        //log.info("repayOrder :{}",order);

        //跳过数据
        if("90000000001".equals(repayOrderInfo.getUserId())){
            throw new MySkipException("skip data");
        }

        return repayOrderInfo;
    }
}
